package com.mht2017.common.utils;

import java.util.Collection;
import java.util.Map;

public class SizeUtil {

	public static int size(Collection<?> list) {
		return null == list ? -1 : list.size();
	}

	public static int sizeZeroIfNull(Collection<?> list) {
		return null == list ? 0 : list.size();
	}

	@Deprecated
	public static int size(Collection<?> list, int emptyValue) {
		return null == list ? emptyValue : list.size();
	}

	public static int size(Map<?, ?> map) {
		return null == map ? -1 : map.size();
	}

	public static int sizeZeroIfNull(Map<?, ?> map) {
		return null == map ? 0 : map.size();
	}

	public static int size(String string) {
		return null == string ? -1 : string.length();
	}

	public static int size(Object[] array) {
		return null == array ? -1 : array.length;
	}

	public static int sizeZeroIfNull(Object[] array) {
		return null == array ? 0 : array.length;
	}

	@Deprecated
	public static int size(Object[] array, int emptyValue) {
		return null == array ? emptyValue : array.length;
	}

	public static int size(byte[] array) {
		return null == array ? -1 : array.length;
	}

	public static int sizeZeroIfNull(byte[] array) {
		return null == array ? 0 : array.length;
	}

	public static boolean isEmpty(Object[] array) {
		return size(array, 0) == 0;
	}

	public static boolean isNotEmpty(Object[] array) {
		return size(array, 0) != 0;
	}

}
